﻿@model SportStore.Domain.Entities.CartIndexViewModel

@{ 
    ViewBag.Title = "SportStore : Your Cart";
}
<style>
    #cartTable td {vertical-align:middle;}
</style>

<h2>Your Cart</h2>
<table id="cartTable" class="table">
    <thead>
        <tr>
            <th>Quantity</th>
            <th>Item</th>
            <th class="text-right">Price</th>
            <th class="text-right">Subtotal</th>
            <th class="text-center">Action</th>
        </tr>
    </thead>
    <tbody>
        @foreach(var line in Model.Cart.Lines)
        {
            <tr>
                <td class="text-center">@line.Quantity</td>
                <td class="text-center">@line.Product.Name</td>
                <td class="text-right">@line.Product.Price.ToString("c")</td>
                <td class="text-right">@((line.Product.Price*line.Quantity).ToString("c"))</td>
                <td class="text-center">
                    @using (Html.BeginForm("RemoveFromCart", "Cart"))
                    {
                        @Html.Hidden("ProductId", line.Product.ProductId)
                        @Html.HiddenFor(x=>x.ReturnUrl)
                        <input class="btn btn-sm btn-warning" type="submit" value="Remove" />
                    }
                </td>
            </tr>
        }
    </tbody>
    <tfoot>
        <tr>
            <td colspan="4" class="text-right">TOTAL:</td>
            <td class="text-right">@Model.Cart.ComputeTotalValue().ToString("c")</td>
        </tr>
    </tfoot>
</table>

<div class="text-center">
    <a class="btn btn-primary" href="@Model.ReturnUrl">Continue Shopping</a>
    @Html.ActionLink("CheckOut Now","CheckOut",null,new { @class = "btn btn-primary" })
</div>